package com.duowei.diandan.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.preference.PreferenceManager;
import android.util.Log;

import com.duowei.diandan.R;
import com.duowei.diandan.activity.SettingsActivity;


public class BootCompletedReceiver extends BroadcastReceiver {
    private static final String TAG = "BootCompletedReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {

        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
        boolean boot = sharedPref.getBoolean(context.getString(R.string.pref_key_boot), false);
        Log.d(TAG, "onReceive: boot = " + boot);
        if (boot) {
            Intent i = new Intent(new Intent(context, SettingsActivity.class));
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
        }
    }
}
